package com.qs.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.qs.entity.MoonMessage;
import com.qs.imp.MoonMessageImp;

public class MoonMessageAction extends ActionSupport {
	private MoonMessage moonmessage;
	private String forwordURL;
	private String friendUserName;
	private int moonId;
	private int flag;
	private int moonMessageId;
	
	
	

	public int getMoonMessageId() {
		return moonMessageId;
	}

	public void setMoonMessageId(int moonMessageId) {
		this.moonMessageId = moonMessageId;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String getForwordURL() {
		return forwordURL;
	}

	public void setForwordURL(String forwordURL) {
		this.forwordURL = forwordURL;
	}

	public int getMoonId() {
		return moonId;
	}

	public void setMoonId(int moonId) {
		this.moonId = moonId;
	}

	public String getFriendUserName() {
		return friendUserName;
	}

	public void setFriendUserName(String friendUserName) {
		this.friendUserName = friendUserName;
	}

	public MoonMessage getMoonmessage() {
		return moonmessage;
	}

	public void setMoonmessage(MoonMessage moonmessage) {
		this.moonmessage = moonmessage;
	}



	public String aMoonReply() throws Exception{
		moonmessage.setMoonMessageId(moonMessageId);
		moonmessage.setUserName(friendUserName);
		moonmessage.setMoonId(moonId);
		System.out.println(moonmessage.getMoonId());
		MoonMessageImp moonmessageimp  = new MoonMessageImp();
		moonmessageimp.addMoonMessage(moonmessage);
		sMoonReply();
		if(flag==0){
			this.forwordURL="userfriendmoonreply.jsp";
		}else{
			this.forwordURL="moonreply.jsp";
		}
		return SUCCESS;
	}
	
	
	
	public String sMoonReply() throws Exception{
		List list = new ArrayList<MoonMessage>();
		MoonMessageImp moonmessageimp  = new MoonMessageImp();
		list =  moonmessageimp.sMoonMessage(moonId);
		ActionContext.getContext().getSession().put("MOONREPLY", list);
		if(flag==0){
			this.forwordURL="userfriendmoonreply.jsp";
		}else{
			this.forwordURL="moonreply.jsp";
		}
		return SUCCESS;
	}
	
}
